// JavaScript Document

function getHTTPObject(){
   if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
   else if (window.XMLHttpRequest) return new XMLHttpRequest();
   else {
      alert("Su navegador no soporta AJAX.");
      return null;
   }
}


function Get_Page(pg,id_div){
	
	httpObject = getHTTPObject();

	if (httpObject != null) {
		
		httpObject.open("POST", "controller/controller.php", true);
		httpObject.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		httpObject.send("pg="+pg);
		httpObject.onreadystatechange = function(){
	
		   	if(httpObject.readyState == 4){
			   							
				document.getElementById(id_div).innerHTML = httpObject.responseText;
										   
			}else{
			   
			     
		
			}		   
		   
	  };
	  
	  
   }
   
}

function Change_State_Form(state){
	
	if(state==10){
		var newdiv = document.getElementById('div_open_data');
		newdiv.style.backgroundImage="url(../image/open_data_sirep.png)";
	}
	
	if(state==11){
		var newdiv = document.getElementById('div_open_data');
		newdiv.style.backgroundImage="url(../image/open_data_over_sirep.png)";
	}
	
	if(state==20){
		var newdiv = document.getElementById('div_open_data');
		newdiv.style.backgroundImage="url(../image/close_data_sirep.png)";
	}
	
	if(state==21){
		var newdiv = document.getElementById('div_open_data');
		newdiv.style.backgroundImage="url(../image/close_data_over_sirep.png)";
	}
}


var height=44;

function Open_Form(id_form,limitsup){
	
	//alert(limitsup);
	var newdiv = document.getElementById(id_form);
	newdiv.style.backgroundImage="url(../image/bg_frm_data_personal_sirep.png)";
	
	document.getElementById('div_footer_data').style.visibility="visible";	
	document.getElementById('div_footer_data').style.height="19px";
	
	height += 3;
	
	if(height<limitsup){
		
		newdiv.style.height=height+'px';	
		window.setTimeout("Open_Form('"+id_form+"',"+limitsup+");",1);
	
	}
	
	if(height==limitsup){	
						
		//document.getElementById(id_form).innerHTML='<div id="div_open_data" onclick="Close_Form(\'div_data_personal\',44,'+limitsup+')" onmouseover="Change_State_Form(21)" onmouseout="Change_State_Form(20)"></div>';
		
		var newdiv = document.getElementById('div_open_data');
		newdiv.style.backgroundImage="url(../image/close_data_sirep.png)";
		
	}
	
}


function Close_Form(id_form,limitinf,limitsup){
	
	//alert(init);
		
	var newdiv = document.getElementById(id_form);
	
	height -= 1;
	
	if (!(height<limitinf)){
		
		newdiv.style.height=height+'px';
		window.setTimeout("Close_Form('"+id_form+"',"+limitinf+","+limitsup+");",1);
		
	}
	
	if(height==limitinf){
		
		//document.getElementById(id_form).innerHTML='<div id="div_open_data" onclick="Open_Form(\'div_data_personal\','+limitsup+')"  onmouseover="Change_State_Form(11)" onmouseout="Change_State_Form(10)"></div>';
		
		var newdiv = document.getElementById(id_form);
		newdiv.style.backgroundImage="url(../image/data_personal_sirep.png)";
		
		var newdiv = document.getElementById('div_open_data');
		newdiv.style.backgroundImage="url(../image/open_data_sirep.png)";
		
		document.getElementById('div_footer_data').style.visibility="hidden";
		document.getElementById('div_footer_data').style.height="0px";	
		
	}
	
}


function solamenteNumeroAndEnter(e)
{	
		
	if (e.which)
	  {
	  	if(e.which!=46 && e.which!=8 && e.wich!=9 && (e.which<48 || e.which>57)){
	  	
			if(e.which!=13){
				return false;
			}
			
			if(e.which==13){
				//alert(e.which);
				//GetMainDetails(e);
				TabsVC(e);
				return true;
			}
		}
	  }
	else if(e.keyCode)
	  {
	  	if(e.keyCode!=46 && e.keyCode!=8 && e.keyCode!=9 && (e.keyCode<48 || e.keyCode>57)){
	  
	 	 	if(e.keyCode!=13){
	  			return false;
			}
			
			if(e.keyCode==13){
				//alert(e.keyCode);
				//GetMainDetails(e);
				TabsVC(e);
				return true;
			}
		}
	  }
	  
	return true;
	
}